def leftRotate(arr, k):
    for i in range(k):
        leftRotateByOne(arr)


def leftRotateByOne(arr):
    temp = arr[0]
    for i in range(len(arr) - 1):
        arr[i] = arr[i + 1]
    arr[len(arr) - 1] = temp


arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
leftRotate(arr, 2)
print(arr)

# def leftRotate(arr, k, n):
#     k = k % n
#     g_c_d = gcd(k, n)
#     for i in range(g_c_d):
#         temp = arr[i]
#         j = i
#         while 1:
#             s = j + k
#             if s >= n:
#                 s = s - n
#             if s == i:
#                 break
#             arr[j] = arr[s]
#             j = s
#         arr[j] = temp
#
# def gcd(a, b):
#     if b == 0:
#         return a
#     else:
#         return gcd(b, a % b)
#
#
# arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
# n = len(arr)
# leftRotate(arr, 3, n)
# for i in range(n):
#     print ("%d" % arr[i], end = " ")
